#!/bin/bash

list=None
work_dir=output

POSITIONAL=()
while [[ $# -gt 0 ]]; do
 key="$1"
 case $key in
    -i|--input)
     list=($2)
     shift # past argument
     shift # past value
     ;;
    -o|--output)
     work_dir=($2)
     shift # past argument
     shift # past value
     ;;
     *)
   POSITIONAL+=("$1") # save it in an array for later
     shift # past argument
     ;;
 esac
done


if [[ $list == 'None' ]]; then
    exit 0
fi

n=`cat $list | grep "[a-z0-9A-Z]" | wc -l`

for i in `seq $n`
do
    query=`head -n $i $list | tail -n 1 | awk '{print $1}'`
    class=`head -n $i $list | tail -n 1 | awk '{print $2}'`
    species=`head -n $i $list | tail -n 1 | awk '{print $3}'`
    echo ""
    echo ""
    echo "Runing wth query $query for $class $species"
    echo ""
    echo ""
    /home/gop/zelixir/run_test/DLDB_Search.sh -q $query -c $class -s $species -o $work_dir
    echo ""
done

cd $work_dir
zip -r results.zip results
#rm results
